<?php 
// Header
$this->set('title_for_layout', __("Chỉnh sửa trang tĩnh", true));

$this->left_menu = 'menu/'.$this->params['controller'];
$params = array(
	//'root'	=>	$this->params['named']['root']
);

if (isset($this->params['plugin'])) {
	$params['plugin'] = $this->params['plugin'];
} else {
	$params['plugin'] = null;
}
// -- Load CSS : Begin --

// -- Load CSS : End  --

// Load Javascript
echo $this->Html->script('ckeditor/ckeditor', array('type' => 'text/javascript'));
//echo $this->Html->script('jquery.form');
echo $this->Html->script('/static_pages/js/edit');
?>

<script language="javascript">
$(document).ready(function () {
	$('div.buttons a.delete').click(function() {
		if (!confirm("<?php __("Bạn có thật sự muốn xóa trang tĩnh này?")?>")) {
			return false;
		}
	});
});

</script>

<h2><?php __("Cập nhật trang tĩnh")?></h2>
<?php echo $session->flash()?>

<div class="buttons attop">
	<ul>
		<li><a href="<?php echo $html->url($params + array('plugin' => 'static_pages', 'controller' => 'manage_static_pages', 'action'	=>	'index'))?>" class="back"><?php __("Danh sách trang tĩnh")?></a></li>
		<li><a href="<?php echo $html->url($params + array('plugin' => 'static_pages', 'controller' => 'manage_static_pages', 'action'=>'delete', $this->data['StaticPage']['id']))?>" class="cancel delete"><?php __("Xóa")?></a></li>
		<li><a href="javascript:void(0)" class="save"><?php __("Cập nhật")?></a></li>
	</ul>
</div>

<?php 
echo $form->create('StaticPage', array(
	'url'	=>	
	$params + array(
		'controller'	=>	$this->params['controller'],	
		'action'		=>	'edit'
	),
	'id'		=>	'edit_page_form',
	'enctype'	=>	'multipart/form-data'
));
?>
<fieldset class="form">
<?php 
echo $form->input('id');
echo $form->input('title', array(
	'label'	=>	__("Tiêu đề: ", true),
	'error'	=>	__("Tiêu đề trang không được để trống", true),
	'size'	=> 50
));

if ($configs['Manage']['edit']['show_alias']) {
	echo $form->input('alias', array('label'	=>	__("Alias: ", true)));
} else {
	echo $form->input('alias', array('label'	=>	__("Alias: ", true), 'type' => 'hidden'));
}

/*
if ($configs['StaticPage']['image']['show']):    
    $image = $this->data['StaticPage']['image'];

    $options = array(
    	'name'				=>	$image,
    	'path'				=>	$configs['StaticPage']['image']['uri'],
    	'field_name'		=>	'image',
    	'label'				=>	__('&nbsp;',true),
    	'legend_title'		=>	__('Hình ảnh',true),
    	'delete_image_link'	=>	$html->url($params + array('controller'=>$this->params['controller'], 'action'=>'delete_image'))."/page_id:".$this->data['StaticPage']['id']
    );
    echo $html->form_image($options,array());
endif;
*/
?>

<?php if ($configs['StaticPage']['description']['show']):?>
<div class="input">
<table cellpadding='0' cellspacing='0' border='0' width='100%' class='list-table'>
<tr>
	<td class='label' valign='top'><label for="description"><?php __("Mô tả: ")?></label></td>
	<td>
		<?php
		echo $form->input('description', array('label'	=>	false, 'div'=>false, 'type'=>'textarea'));
		
		if (!isset($configs['StaticPage']['description']['use_rich_text']) || $configs['StaticPage']['description']['use_rich_text']):
		echo $wysiwyg->render("StaticPage.description", 'ckeditor', $configs['StaticPage']['description_config']);
		endif;
		?>
	</td>
</tr>
</table>
</div>
<?php endif;?>

<?php if ($configs['StaticPage']['content']['show']):?>
<div class="input">
<table cellpadding='0' cellspacing='0' border='0' width='100%' class='list-table'>
<tr>
	<td class='label' valign='top'><label for="description"><?php __("Nội dung: ")?></label></td>
	<td>
		<?php
		echo $form->input('content', array('label'	=>	false, 'div'=>false, 'type'=>'textarea'));
		
		if (!isset($configs['StaticPage']['description']['use_rich_text']) || $configs['StaticPage']['description']['use_rich_text']):
		echo $wysiwyg->render("StaticPage.content", 'ckeditor', $configs['StaticPage']['content_config']);
		endif;
		?>
	</td>
</tr>
</table>
</div>
<?php endif;?>

<?php
echo $form->input('is_published', array('label' => __("Kích hoạt?", true)));
?>
<div style="display:none">
	<input type="submit"/>
</div>
</fieldset>
<?php echo $form->end();?>

<div class="buttons attop">
	<ul>
		<li><a href="<?php echo $html->url($params + array('plugin' => 'StaticPage', 'controller' => 'manage_static_pages', 'action'	=>	'index'))?>" class="back"><?php __("Danh sách trang tĩnh")?></a></li>
		<li><a href="<?php echo $html->url($params + array('plugin' => 'StaticPage', 'controller' => 'manage_static_pages', 'action'=>'delete', $this->data['StaticPage']['id']))?>" class="cancel delete"><?php __("Xóa")?></a></li>
		<li><a href="javascript:void(0)" class="save"><?php __("Cập nhật")?></a></li>
	</ul>
</div>